package com.yox.testClient;

import com.yox.rpc.api.ByeService;
import com.yox.rpc.api.HelloObject;
import com.yox.rpc.api.HelloService;
import com.yox.rpc.serializer.CommonSerializer;
import com.yox.rpc.transport.RpcClient;
import com.yox.rpc.transport.RpcClientProxy;
import com.yox.rpc.transport.netty.client.NettyClient;

public class NettyTestClient {
    public static void main(String[] args) {
        // 创建客户端连接Netty服务器,参数是序列化器
        RpcClient client = new NettyClient(CommonSerializer.KRYO_SERIALIZER);
        // 创建客户端代理
        RpcClientProxy rpcClientProxy = new RpcClientProxy(client);
        HelloService helloService = rpcClientProxy.getProxy(HelloService.class);
        // 创建调用信息对象
        HelloObject object1 = new HelloObject(24, "hello Netty!");
        // 远程调用
        String res1 = helloService.hello(object1);
        System.out.println(res1);

        ByeService byeService = rpcClientProxy.getProxy(ByeService.class);
        System.out.println(byeService.bye("Netty"));
    }
}
